@extends("public.main")
@section("content")
    <div style="margin-left:200px;">
        <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 分类管理 <span
                    class="c-gray en">&gt;</span>编辑文章
        </nav>
        <form class="form form-horizontal form-o2o-add" id="form-o2o-add" method="post"
              action="/admin/article/edit/{{$data['id']}}" enctype="multipart/form-data">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>文章名称：</label>
                <div class="formControls col-xs-8 col-sm-5">
                    <input type="text" class="input-text" value="{{ $data['title'] }}" readonly="readonly" placeholder="" id="title" name="title">
                    @if($errors->has('title'))
                        <a style="color:red">{{ $errors->first('title') }}</a>
                    @endif
                    {!!csrf_field()!!}
                </div>
            </div>
            <div class="row cl">

            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>文章内容：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div  style="width: 70%;">
                        <!-- 加载编辑器的容器 -->
                        <script id="container" name="content" type="text/plain"></script>
                        <!-- 配置文件 -->
                        <script type="text/javascript" src="{{ asset('/admin/article/ueditor/ueditor.config.js') }}"></script>
                        <!-- 编辑器源码文件 -->
                        <script type="text/javascript" src="{{ asset('/admin/article/ueditor/ueditor.all.js') }}"></script>
                        <!-- 实例化编辑器 -->

                    </div>
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                    @if($errors->has('content'))
                        <a style="color:red">{{ $errors->first('content') }}</a>
                    @endif
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                    <button type="submit" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe632;</i> 保存
                    </button>
                    <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
                </div>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        var ue = UE.getEditor("container", {
        });
        var content= "{{$data['content']}}";
        ue.addListener("ready", function () {
            // editor准备好之后才可以使用
            ue.setContent(decodeHtml(content));
        });
        function decodeHtml(s) {
            var HTML_DECODE = {
                "&lt;": "<",
                "&gt;": ">",
                "&amp;": "&",
                "&nbsp;": " ",
                "&quot;": "\"",
                "&copy;": ""
                // Add more
            };

            var REGX_HTML_ENCODE = /"|&|'|<|>|[\x00-\x20]|[\x7F-\xFF]|[\u0100-\u2700]/g;

            var REGX_HTML_DECODE = /&\w+;|&#(\d+);/g;

            var REGX_TRIM = /(^\s*)|(\s*$)/g;

            s = (s != undefined) ? s : "";
            return (typeof s != "string") ? s :
                s.replace(REGX_HTML_DECODE,
                    function ($0, $1) {
                        var c = HTML_DECODE[$0];
                        if (c == undefined) {
                            // Maybe is Entity Number
                            if (!isNaN($1)) {
                                c = String.fromCharCode(($1 == 160) ? 32 : $1);
                            } else {
                                c = $0;
                            }
                        }
                        return c;
                    });
        };
    </script>
@endsection
